package edu.ucdavis.gwt.gis.client.config;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;

/**
 * Main config object for application
 * 
 * @author jrmerz
 */
public class GadgetConfig extends JavaScriptObject {
	
	protected GadgetConfig() {}

	/**
	 * Get the list of datalayers
	 * 
	 * @return JsArray<LayerConfig>
	 */
	public final native JsArray<LayerConfig> getDataLayers() /*-{
		if( this.datalayers ) return this.datalayers;
		return [];
	}-*/;

	/**
	 * Get the list of additional basemaps
	 * 
	 * @return JsArray<BasemapConfig>
	 */
	public final native JsArray<BasemapConfig> getAdditionalBasemaps() /*-{
		if( this.basemaps ) return this.basemaps;
		return [];
	}-*/;
	
	/**
	 * Get the provider config object
	 * 
	 * @return Provider Config
	 */
	public final native ProviderConfig getProvider() /*-{
		if( this.provider ) return this.provider;
		return {};
	}-*/;

	/**
	 * Is a center point provided in the config object
	 * 
	 * @return boolean
	 */
	public final native boolean hasCenterPoint() /*-{
		if( this.center ) return true;
		return false;
	}-*/;
	
	/**
	 * get the center x coordinate
	 * 
	 * @return double
	 */
	public final native double getCenterx() /*-{
		if( this.center ) return this.center[0];
		return 0; 
	}-*/;
	
	/**
	 * get the center y coordinate
	 * 
	 * @return double
	 */
	public final native double getCentery() /*-{
		if( this.center ) return this.center[1];
		return 0; 
	}-*/;
	
	/**
	 * get the zoom level
	 * 
	 * @return int
	 */
	public final native int getZoomLevel() /*-{
		if( this.zoom ) return this.zoom;
		return 7;
	}-*/;

	/**
	 * get the div tag this entire application is to be anchored to
	 * 
	 * @return String
	 */
	public final native String getAnchorDiv() /*-{
		if( this.anchor ) return this.anchor;
		return "";
	}-*/;
	
	/**
	 * Get the string that will be appended on to the end of
	 * every geocoder search
	 * 
	 * @return String
	 */
	public final native String getGeocoderBias() /*-{
		if( this.geocoderBias ) return this.geocoderBias;
		return "";
	}-*/;
	
	/**
	 * Get the key the google maps api is to use (domain specific)
	 * 
	 * @return String
	 */
	public final native String getGMapsKey() /*-{
		if( this.gMapsKey ) return this.gMapsKey;
		return "";
	}-*/;
	
	/**
	 * Should the geocoder use the google geocoding service?
	 * 
	 * @return
	 */
	public final native boolean useGmaps() /*-{
		if( this.geocoder ) {
			if( this.geocoder == "google" ) return true;
		}
		return false;
	}-*/;

	/**
	 * Should the geocoder use a custom service?
	 * 
	 * @return
	 */
	public final native boolean useCustomLocator() /*-{
		if( this.geocoder ) {
			if( this.geocoder == "custom" ) return true;
		}
		return false;
	}-*/;

	/**
	 * Title of the application
	 * 
	 * @return String
	 */
	public final native String getTitle() /*-{
		if( this.title ) return this.title;
		return "";
	}-*/;
	
	/**
	 * Url to the python image export script
	 * 
	 * @return String
	 */
	public final native String getExportImageUrl() /*-{
		if( this.exportImageUrl ) return this.exportImageUrl;
		return "";
	}-*/;
	
	/**
	 * Url to the HTML5 page that allows for remote posting of 'cloud stored'
	 * data.
	 * 
	 * @return String
	 */
	public final native String getCloudStoreUrl() /*-{
		if( this.cloudStoreUrl ) return this.cloudStoreUrl;
		return "";
	}-*/;
	
	/**
	 * Url to the python script that grabs cloud stored data base on id.
	 * 
	 * @return String
	 */
	public final native String getCloudGetUrl() /*-{
		if( this.cloudGetUrl ) return this.cloudGetUrl;
		return "";
	}-*/;
	
	public final native String getGeometryServer() /*-{
		if( this.geometryServer ) return this.geometryServer;
		return "";
	}-*/;
	

	public final native boolean enabledQueryTool() /*-{
		if( this.queryTool ) return this.queryTool;
		return false;
	}-*/;
	
}
